<template>
  <div id="app">
    <Header :key="updateKey" @updateKeyFn="updateKeyFn" />
    <Nav />
    <router-view @updateKeyFn="updateKeyFn" />
    <Footer />
    <Login @updateKeyFn="updateKeyFn" />
    <transition name="fade">
      <Toast v-show="$store.state.toast.show" />
    </transition>
  </div>
</template>

<script>
import Header from './components/Header.vue';
import Nav from './components/Nav.vue';
import Login from './components/Login.vue';
import Toast from './components/Toast.vue';
import Footer from './components/Footer.vue';
export default {
  data() {
    return {
      updateKey: 0
    }
  },
  components: {
    Header,
    Nav,
    Login,
    Toast,
    Footer
  },
  methods: {
    // 更新header
    updateKeyFn() {
      console.log(1);
      this.updateKey++;
    }
  },
  watch: {
    "$route.query": {
      handler(newVal, oldVal) {
        let _this = this;
        if (_this.$route.query.code) {
          _this.componentKey++;
        }
      },
      deep: true,
    },
  }
}
</script>
 
<style lang = "less" scoped>
body {
  background: #f5f5f5;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s linear;
}

.fade-enter,
.fade-leave-to

/* .fade-leave-active below version 2.1.8 */
  {
  opacity: 0;
}

.fade-enter-to,
.fade-leave {
  opacity: 1;
}

img[lazy="loading"] {
  display: block;
  width: 30% !important;
  height: 30% !important;
  margin: 0 auto;
}
</style>